package com.bluexmicro.ota2.ui.screen.config.bxlink;

public class CommonUtils {

    public static int toUInt16(byte high, byte low) {
        return (low & 0xff) | ((high << 8) & 0xff00);
    }

    /**
     * 字节数组转16进制字符串
     *
     * @param b 字节数组
     * @return 16进制字符串
     */
    public static String byte2hex(byte[] b) {
        StringBuilder hs = new StringBuilder();
        String stmp;
        for (byte value : b) {
            stmp = Integer.toHexString(value & 0xFF);
            if (stmp.length() == 1) {
                hs.append("0").append(stmp);
            } else {
                hs.append(stmp);
            }
        }
        return hs.toString();
    }
}
